home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / cron < prev    next >
Encoding:
Text File  |  2010-12-18  |  3.7 KB  |  105 lines

  1. #!/bin/sh
  2. # Start/stop the cron daemon.
  3. #
  4. ### BEGIN INIT INFO
  5. # Provides:          cron
  6. # Required-Start:    $remote_fs $syslog $time
  7. # Required-Stop:     $remote_fs $syslog $time
  8. # Should-Start:      $named slapd autofs ypbind nscd nslcd
  9. # Should-Stop:       $named slapd autofs ypbind nscd nslcd
  10. # Default-Start:     2 3 4 5
  11. # Default-Stop:
  12. # Short-Description: Regular background program processing daemon
  13. # Description:       cron is a standard UNIX program that runs user-specified 
  14. #                    programs at periodic scheduled times. vixie cron adds a 
  15. #                    number of features to the basic UNIX cron, including better
  16. #                    security and more powerful configuration options.
  17. ### END INIT INFO
  18.  
  19.  
  20. test -f /usr/sbin/cron || exit 0
  21.  
  22. PIDFILE=/var/run/crond.pid
  23. # In some systems the pidfile might be (incorrectly) set to /etc
  24. # if this pidfile is present, use it instead.
  25. [ -e /etc/cron.pid ] && PIDFILE=/etc/crond.pid
  26. [ -r /etc/default/cron ] && . /etc/default/cron
  27.  
  28. . /lib/lsb/init-functions
  29.  
  30.  
  31. # Read the system's locale and set cron's locale. This is only used for
  32. # setting the charset of mails generated by cron. To provide locale
  33. # information to tasks running under cron, see /etc/pam.d/cron.
  34. #
  35. # We read /etc/environment, but warn about locale information in
  36. # there because it should be in /etc/default/locale.
  37. parse_environment () 
  38. {
  39.     for ENV_FILE in /etc/environment /etc/default/locale; do
  40.         [ -r "$ENV_FILE" ] || continue
  41.         [ -s "$ENV_FILE" ] || continue
  42.  
  43.          for var in LANG LANGUAGE LC_ALL LC_CTYPE; do
  44.              value=`egrep "^${var}=" "$ENV_FILE" | tail -n1 | cut -d= -f2`
  45.              [ -n "$value" ] && eval export $var=$value
  46.  
  47.              if [ -n "$value" ] && [ "$ENV_FILE" = /etc/environment ]; then
  48.                  log_warning_msg "/etc/environment has been deprecated for locale information; use /etc/default/locale for $var=$value instead"
  49.              fi
  50.          done
  51.      done
  52.  
  53. # Get the timezone set.
  54.     if [ -z "$TZ" -a -e /etc/timezone ]; then
  55.         TZ=`cat /etc/timezone` 
  56.     fi
  57. }
  58.  
  59. # Parse the system's environment
  60. if [ "$READ_ENV" = "yes" ] ; then
  61.     export LANG LC_ALL LC_CTYPE TZ LC_COLLATE
  62.     parse_environment
  63.     LC_COLLATE=C # Force collation sequence since ASCII is expected in regexps
  64. fi
  65.  
  66.  
  67. case "$1" in
  68. start)    log_daemon_msg "Starting periodic command scheduler" "cron"
  69.         start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
  70.         log_end_msg $?
  71.     ;;
  72. stop)    log_daemon_msg "Stopping periodic command scheduler" "cron"
  73.         start-stop-daemon --stop --quiet --pidfile $PIDFILE --name cron
  74.         log_end_msg $?
  75.         ;;
  76. restart) log_daemon_msg "Restarting periodic command scheduler" "cron" 
  77.         start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE --name cron
  78.         start-stop-daemon --start --quiet --pidfile $PIDFILE --name cron --startas /usr/sbin/cron -- $LSBNAMES $EXTRA_OPTS
  79.         log_end_msg $?
  80.         ;;
  81. reload|force-reload) log_daemon_msg "Reloading configuration files for periodic command scheduler" "cron"
  82.     # cron reloads automatically
  83.         log_end_msg 0
  84.         ;;
  85. status)
  86.        log_action_begin_msg "Checking periodic command scheduler"
  87.        if pidofproc -p "$PIDFILE" >/dev/null; then
  88.             log_action_end_msg 0 "running"
  89.             exit 0
  90.        else
  91.            if [ -e "$PIDFILE" ]; then
  92.                 log_action_end_msg 1 "failed to start"
  93.                 exit 1
  94.            else
  95.                 log_action_end_msg 0 "not running"
  96.                 exit 3
  97.            fi
  98.        fi
  99.          ;;
  100. *)    log_action_msg "Usage: /etc/init.d/cron {start|stop|status|restart|reload|force-reload}"
  101.         exit 2
  102.         ;;
  103. esac
  104. exit 0
  105.